package com.belizer.springboot.graphql;

import graphql.GraphQL;
import graphql.kickstart.tools.SchemaParser;
import graphql.schema.GraphQLSchema;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



@Configuration
@RequiredArgsConstructor
public class GraphQLProvider {
    private final ItemSerice itemSerice;

    @Bean
    public GraphQL graphQL() {

        GraphQLSchema graphQLSchema = SchemaParser.newParser()
                .file("graphql/base.graphqls")
                .resolvers(new Query(), new Mutation())
                .file("graphql/item.graphqls")
                .resolvers(new ItemResolver(itemService))
//            .file("book.graphqls")
//            .resolvers(new BookResolver())  //其它定义照上面的示例，继续增加
                .build().makeExecutableSchema();

        return GraphQL.newGraphQL(graphQLSchema).build();
    }





}
